<?php

/*
 * This file is part of the gedongdong/laravel_rbac_permission.
 *
 * (c) gedongdong <gedongdong2010@163.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

/**
 * 基础, 不需要验证登录态
 */
Route::any('login', 'Auth\\LoginController@login')->name('login'); // 登录接口 带name, 是因为Auth中间件要求要有
Route::any('login_out', 'Auth\\LoginController@loginOut'); // 登录接口
Route::post('register', 'Auth\\LoginController@register'); // 注册接口

/**
 * 对接口进行分组操作
 *     namespace  =>  指代当前分组中所有的控制器的namespace放在指定域中
 *                         比如  {namespace}/{控制器}Controller@{方法名称}
 *     prefix     =>  指代接口下面所有接口, 前置需要带的请求标识
 *                         比如  {{base_url}}/api/v1/{接口名称}
 *     middleware =>  中间件, 对于的所有的控制器方法执行钱, 都需要先执行中间件
 *                         比如  Auth 中间件, 就需要在app\Http\Kernel.php文件中, 查找中间件名称为 auth 对应的中间件
 *                              单独调用 中间件也可以使用 Route::middleware('auth:api')->group(function () {});
 */
Route::group(['namespace' => 'Auth', 'prefix' => 'v1', 'middleware' => 'auth:api'], function ($route) {
    $route->get('user', function (Request $request) {
        return $request->user();
    });
    $route->get('myself', 'UserController@myself');
});
